home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1990: Discy Business / Discy Business.2mg / DEV.CD / TOOLS / APW.Interfaces / CInclude / TextEdit.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-03-01  |  13.7 KB  |  441 lines  |  [04] ASCII Text (0x0000)

  1. /********************************************
  2. ; File: TextEdit.h
  3. ;
  4. ;
  5. ; Copyright Apple Computer, Inc.1986-90
  6. ; All Rights Reserved
  7. ;
  8. ********************************************/
  9. #ifndef __TYPES__
  10. #include <TYPES.h>
  11. #endif
  12.  
  13. #ifndef __QUICKDRAW__
  14. #include <QUICKDRAW.h>
  15. #endif
  16.  
  17. #ifndef __EVENT__
  18. #include <EVENT.h>
  19. #endif
  20.  
  21. #ifndef __FONT__
  22. #include <FONT.h>
  23. #endif
  24.  
  25. #ifndef __GSOS__
  26. #include <GSOS.h>
  27. #endif
  28.  
  29. #ifndef __RESOURCES__
  30. #include <RESOURCES.h>
  31. #endif
  32.  
  33. #ifndef __CONTROL__
  34. #include <CONTROL.h>
  35. #endif
  36.  
  37. #ifndef __TEXTEDIT__
  38. #define __TEXTEDIT__
  39.  
  40.  
  41. /* Error Codes */
  42. #define teAlreadyStarted 0x2201
  43. #define teNotStarted 0x2202
  44. #define teInvalidHandle 0x2203
  45. #define teInvalidVerb 0x2204
  46. #define teInvalidFlag 0x2205
  47. #define teInvalidPCount 0x2206
  48. #define teInvalidRect 0x2207
  49. #define teBufferOverflow 0x2208
  50. #define teInvalidLine 0x2209
  51. #define teInvalidCall 0x220A
  52.  
  53. /* TE Verbs */
  54. #define NullVerb 0x0000
  55. #define PStringVerb 0x0001
  56. #define CStringVerb 0x0002
  57. #define C1InputVerb 0x0003
  58. #define C1OutputVerb 0x0004
  59. #define HandleVerb 0x0005
  60. #define PointerVerb 0x0006
  61. #define NewPStringVerb 0x0007
  62. #define fEqualLineSpacing 0x8000
  63. #define fShowInvisibles 0x4000
  64. #define teInvalidDescriptor 0x2204
  65. #define teInvalidParameter 0x220B
  66. #define teInvalidTextBox2 0x220C
  67. #define teNeedsTools 0x220D  /* 8717 */
  68. #define teEqualLineSpacing 0x8000
  69. #define teShowInvisibles 0x4000
  70.  
  71. /* Justification Values */
  72. #define leftJust 0x0000
  73. #define rightJust 0xFFFF
  74. #define centerJust 0x0001
  75. #define fullJust 0x0002
  76.  
  77. /* TERuler.tabType Codes */
  78. #define noTabs 0x0000
  79. #define stdTabs 0x0001  /* Tabs every tabTerminator pixels */
  80. #define absTabs 0x0002  /* Tabs at absolute location specified by theTabs array */
  81.  
  82. /* TEParamBlock.flags Codes */
  83. #define fCtlInvis 0x0080
  84. #define fRecordDirty 0x0040
  85.  
  86. /* TE Tab Codes */
  87. #define teLeftTab 0x0000
  88. #define teCenterTab 0x0001
  89. #define teRightTab 0x0002
  90. #define teDecimalTab 0x0003
  91.  
  92. /* TEParamBlock.textFlags Codes */
  93. #define fNotControl 0x80000000L  /* TextEdit record is not a control */
  94. #define fSingleFormat 0x40000000L  /* Only one ruler is allowed for record */
  95. #define fSingleStyle 0x20000000L  /* Only one style is allowed for record */
  96. #define fNoWordWrap 0x10000000L  /* No word wrap is performed */
  97. #define fNoScroll 0x08000000L  /* The text cannot scroll */
  98. #define fReadOnly 0x04000000L  /* The text cannot be edited */
  99. #define fSmartCutPaste 0x02000000L  /* Record supports intelligent cut and paste */
  100. #define fTabSwitch 0x01000000L  /* Tab key switches user to next TextEdit record on the screen */
  101. #define fDrawBounds 0x00800000L  /* TextEdit draw a box around text */
  102. #define fColorHilight 0x00400000L  /* Use color table for highlighting */
  103. #define fGrowRuler 0x00200000L  /* Adjust right margin whenever window size changes */
  104. #define fDisableSelection 0x00100000L  /* User cannot select or edit text */
  105. #define fDrawInactiveSelection 0x00080000L  /* TextEdit displays a box around an inactive selection */
  106.  
  107. /* Descriptor Codes */
  108. #define teCtlColorIsPtr 0x0000
  109. #define teCtlColorIsHandle 0x0004
  110. #define teCtlColorIsResource 0x0008
  111. #define teCtlStyleIsPtr 0x0000
  112. #define teCtlStyleIsHandle 0x0001
  113. #define teCtlStyleIsResource 0x0002
  114. #define teRefIsPtr 0x0000
  115. #define teRefIsHandle 0x0001
  116. #define teRefIsResource 0x0002
  117. #define teRefIsNewHandle 0x0003
  118. #define teDataIsPString 0x0000
  119. #define teDataIsCString 0x0001
  120. #define teDataIsC1Input 0x0002
  121. #define teDataIsC1Output 0x0003
  122. #define teDataIsTextBox2 0x0004
  123. #define teDataIsTextBlock 0x0005
  124. #define teTextIsPtr 0x0000
  125. #define teTextIsHandle 0x0008
  126. #define teTextIsResource 0x0010
  127. #define teTextIsNewHandle 0x0018
  128.  
  129. /* TEGetLastError clearFlag Codes */
  130. #define fLeaveError 0x0000  /* Leave the last error code intact */
  131. #define fClearError 0xFFFF  /* Clear the last error code */
  132.  
  133. /* Other Constants */
  134. #define teInvis 0x4000
  135. #define tePartialLines 0x8000L
  136. #define teDontDraw 0x4000
  137. #define teUseFont 0x0020
  138. #define teUseSize 0x0010
  139. #define teUseForeColor 0x0008
  140. #define teUseBackColor 0x0004
  141. #define teUseUserData 0x0002
  142. #define teUseAttributes 0x0001
  143. #define teReplaceFont 0x0040
  144. #define teReplaceSize 0x0020
  145. #define teReplaceForeColor 0x0010
  146. #define teReplaceBackColor 0x0008
  147. #define teReplaceUserField 0x0004
  148. #define teReplaceAttributes 0x0002
  149. #define teSwitchAttributes 0x0001
  150.  
  151. /* Filter Procedure Commands */
  152. #define doEraseRect 0x0001
  153. #define doEraseBuffer 0x0002
  154. #define doRectChanged 0x0003
  155. #define doKeyStroke 0x0004
  156.  
  157. /* TEScroll descriptors */
  158. #define teScrollAbsTop 0x0000  /* 0 */
  159. #define teScrollAbsCenter 0x0001  /* 1 */
  160. #define teScrollLineTop 0x0002  /* 2 */
  161. #define teScrollLineCenter 0x0003  /* 3 */
  162. #define teScrollAbsUnit 0x0004  /* 4 */
  163. #define teScrollRelUnit 0x0005  /* 5 */
  164. struct TETextBlock {
  165.    struct TETextBlock **nextHandle; /* Handle to next TextBlock in list */
  166.    struct TETextBlock **prevHandle; /* Handle to previous TextBlock in list */
  167.    LongWord textLength; /* Number of bytes of theText */
  168.    Word flags;
  169.    Word reserved; /* Reserved */
  170.    Byte theText[1]; /* textLength bytes of text  */
  171. } ;
  172. typedef struct TETextBlock TETextBlock, *TETextBlockPtr, **TETextBlockHndl;
  173. struct TETextList {
  174.    TETextBlockHndl cachedHandle; /* Handle to current TextBlock */
  175.    LongWord cachedOffset; /* Text offset of the start of the current TextBlock */
  176. } ;
  177. typedef struct TETextList TETextList, *TETextListPtr, **TETextListHndl;
  178. struct TEColorTable {
  179.    Word contentColor;
  180.    Word outlineColor;
  181.    Word hiliteForeColor;
  182.    Word hiliteBackColor;
  183.    Word vertColorDescriptor;
  184.    LongWord vertColorRef;
  185.    Word horzColorDescriptor;
  186.    LongWord horzColorRef;
  187.    Word growColorDescriptor;
  188.    LongWord growColorRef;
  189. } ;
  190. typedef struct TEColorTable TEColorTable, *TEColorTablePtr, **TEColorTableHndl;
  191. struct TEBlockEntry {
  192.    Handle text; /*   */
  193.    Handle length; /*   */
  194.    Word flags; /*   */
  195. } ;
  196. typedef struct TEBlockEntry TEBlockEntry;
  197. struct TEBlocksRecord {
  198.    LongWord start; /*   */
  199.    Word index; /*   */
  200.    TEBlockEntry blocks[1]; /*   */
  201. } ;
  202. typedef struct TEBlocksRecord TEBlocksRecord, *TEBlocksPtr, **TEBlocksHndl;
  203. struct TabItem {
  204.    Word tabKind;
  205.    Word tabData;
  206. } ;
  207. typedef struct TabItem TabItem;
  208. struct TESuperItem {
  209.    LongWord itemLength; /*   */
  210.    LongWord itemData; /*   */
  211. } ;
  212. typedef struct TESuperItem TESuperItem, *TESuperItemPtr, **TESuperItemHndl;
  213. struct TESuperBlock {
  214.    struct TESuperBlock **nextHandle; /*   */
  215.    struct TESuperBlock **prevHandle; /*   */
  216.    LongWord textLength; /*   */
  217.    LongWord reserved; /*   */
  218.    TESuperItem theItems[1]; /*   */
  219. } ;
  220. typedef struct TESuperBlock TESuperBlock, *TESuperBlockPtr, **TESuperBlockHndl;
  221. struct TESuperHandle {
  222.    TESuperBlockHndl cachedHandle; /*   */
  223.    LongWord cachedOffset; /*   */
  224.    Word cachedIndex; /*   */
  225.    Word itemsPerBlock; /*   */
  226. } ;
  227. typedef struct TESuperHandle TESuperHandle, *TESuperHandlePtr, **TESuperHandleHndl;
  228. struct TERuler {
  229.    Word leftMargin;
  230.    Word leftIndent;
  231.    Word rightMargin;
  232.    Word just;
  233.    Word extraLS;
  234.    Word flags;
  235.    LongWord userData;
  236.    Word tabType;
  237.    TabItem theTabs[1];
  238.    Word tabTerminator;
  239. } ;
  240. typedef struct TERuler TERuler, *TERulerPtr, **TERulerHndl;
  241. struct TEStyle {
  242.    FontID styleFontID;
  243.    Word foreColor;
  244.    Word backColor;
  245.    LongWord userData;
  246. } ;
  247. typedef struct TEStyle TEStyle;
  248. struct TEStyleGroup {
  249.    Word count; /*   */
  250.    TEStyle styles[1]; /*   */
  251. } ;
  252. typedef struct TEStyleGroup TEStyleGroup, *TEStyleGroupPtr, **TEStyleGroupHndl;
  253. struct StyleItem {
  254.    LongWord dataLength; /* Number of text characters using the style */
  255.    LongWord dataOffset; /* Byte offset into theStyleList entry */
  256. } ;
  257. typedef struct StyleItem StyleItem, *StyleItemPtr, **StyleItemHndl;
  258. typedef long TERulerRef;
  259.  
  260. /*
  261.     The following data structure (TEFormat) is for reference only!
  262.     It contains embedded variable length fields.
  263. */
  264.  
  265. struct TEFormat {
  266.    Word version;
  267.    LongWord rulerListLength;
  268.    TERuler theRulerList[1];
  269.    LongWord styleListLength;
  270.    TEStyle theStyleList[1];
  271.    LongWord numberOfStyles;
  272.    StyleItem theStyles[1];
  273. } ;
  274. typedef struct TEFormat TEFormat, *TEFormatPtr, **TEFormatHndl;
  275. typedef struct TETextRef {
  276.      Ptr TETextDesc;
  277. } TETextRef,*TETextRefPtr, **TETextRefHndl;
  278.  
  279. typedef struct TEStyleRef {
  280.       Ptr TEStyleDesc ;
  281. } TEStyleRef,*TEStyleRefPtr,**TEStyleRefHndl ;
  282.  
  283. typedef long TEColorRef;
  284. struct TEParamBlock {
  285.    Word pCount;
  286.    LongWord controlID;
  287.    Rect boundsRect;
  288.    LongWord procRef;
  289.    Word flags;
  290.    Word moreflags;
  291.    LongWord refCon;
  292.    LongWord textFlags;
  293.    Rect indentRect;
  294.    CtlRecHndl vertBar;
  295.    Word vertAmount;
  296.    CtlRecHndl horzBar;
  297.    Word horzAmount;
  298.    TEStyleRef styleRef;
  299.    Word textDescriptor;
  300.    TETextRef textRef;
  301.    LongWord textLength;
  302.    LongWord maxChars;
  303.    LongWord maxLines;
  304.    Word maxCharsPerLine;
  305.    Word maxHeight;
  306.    TEColorRef colorRef;
  307.    Word drawMode;
  308.    ProcPtr filterProcPtr;
  309. } ;
  310. typedef struct TEParamBlock TEParamBlock, *TEParamBlockPtr, **TEParamBlockHndl;
  311. struct TEInfoRec {
  312.    LongWord charCount; /*   */
  313.    LongWord lineCount; /*   */
  314.    LongWord formatMemory; /*   */
  315.    LongWord totalMemory; /*   */
  316.    LongWord styleCount; /*   */
  317.    LongWord rulerCount; /*   */
  318. } ;
  319. typedef struct TEInfoRec TEInfoRec;
  320. struct TEHooks {
  321.    ProcPtr charFilter; /*   */
  322.    ProcPtr wordWrap; /*   */
  323.    ProcPtr wordBreak; /*   */
  324.    ProcPtr drawText; /*   */
  325.    ProcPtr eraseText; /*   */
  326. } ;
  327. typedef struct TEHooks TEHooks;
  328. struct TEKeyRecord {
  329.    Word theChar; /*   */
  330.    Word theModifiers; /*   */
  331.    Handle theInputHandle; /*   */
  332.    LongWord cursorOffset; /*   */
  333.    Word theOpCode; /*   */
  334. } ;
  335. typedef struct TEKeyRecord TEKeyRecord, *TEKeyRecordPtr, **TEKeyRecordHndl;
  336. struct TERecord {
  337.    CtlRecHndl ctrlNext; /*   */
  338.    WindowPtr inPort; /*   */
  339.    Rect boundsRect; /*   */
  340.    Byte ctrlFlag; /*   */
  341.    Byte ctrlHilite; /*   */
  342.    Word lastErrorCode; /*   */
  343.    ProcPtr ctrlProc; /*   */
  344.    ProcPtr ctrlAction; /*   */
  345.    ProcPtr filterProc; /*   */
  346.    LongWord ctrlRefCon; /*   */
  347.    TEColorTablePtr colorRef; /*   */
  348.    LongWord textFlags; /*   */
  349.    LongWord textLength; /*   */
  350.    TETextList blockList; /*   */
  351.    LongWord ctrlID; /*   */
  352.    Word ctrlMoreFlags; /*   */
  353.    Word ctrlVersion; /*   */
  354.    Rect viewRect; /*   */
  355.    LongWord totalHeight; /*   */
  356.    TESuperHandle lineSuper; /*   */
  357.    TESuperHandle styleSuper; /*   */
  358.    Handle styleList; /*   */
  359.    Handle rulerList; /*   */
  360.    Boolean lineAtEndFlag; /*   */
  361.    LongWord selectionStart; /*   */
  362.    LongWord selectionEnd; /*   */
  363.    Word selectionActive; /*   */
  364.    Word selectionState; /*   */
  365.    LongWord caretTime; /*   */
  366.    Boolean nullStyleActive; /*   */
  367.    TEStyle nullStyle; /*   */
  368.    LongWord topTextOffset; /*   */
  369.    Word topTextVPos; /*   */
  370.    CtlRecHndl vertScrollBar; /*   */
  371.    LongWord vertScrollPos; /*   */
  372.    LongWord vertScrollMax; /*   */
  373.    Word vertScrollAmount; /*   */
  374.    CtlRecHndl horzScrollBar; /*   */
  375.    LongWord horzScrollPos; /*   */
  376.    LongWord horzScrollMax; /*   */
  377.    Word horzScrollAmount; /*   */
  378.    CtlRecHndl growBoxHandle; /*   */
  379.    LongWord maximumChars; /*   */
  380.    LongWord maximumLines; /*   */
  381.    Word maxCharsPerLine; /*   */
  382.    Word maximumHeight; /*   */
  383.    Word textDrawMode; /*   */
  384.    ProcPtr wordBreakHook; /*   */
  385.    ProcPtr wordWrapHook; /*   */
  386.    ProcPtr keyFilter; /*   */
  387.    Rect theFilterRect; /*   */
  388.    Word theBufferVPos; /*   */
  389.    Word theBufferHPos; /*   */
  390.    TEKeyRecord theKeyRecord; /*   */
  391.    LongWord cachedSelcOffset; /*   */
  392.    Word cachedSelcVPos; /*   */
  393.    Word cachedSelcHPos; /*   */
  394.    Rect mouseRect; /*   */
  395.    LongWord mouseTime; /*   */
  396.    Word mouseKind; /*   */
  397.    Point lastClick; /*   */
  398.    Word savedHPos; /*   */
  399.    LongWord anchorPoint; /*   */
  400. } ;
  401. typedef struct TERecord TERecord, *TERecordPtr, **TERecordHndl;
  402. extern pascal void TEActivate() inline(0x0F22,dispatcher);
  403. extern pascal void TEBootInit() inline(0x0122,dispatcher);
  404. extern pascal void TEClear() inline(0x1922,dispatcher);
  405. extern pascal void TEClick() inline(0x1122,dispatcher);
  406. extern pascal void TECompactRecord() inline(0x2822,dispatcher);
  407. extern pascal void TECopy() inline(0x1722,dispatcher);
  408. extern pascal void TECut() inline(0x1622,dispatcher);
  409. extern pascal void TEDeactivate() inline(0x1022,dispatcher);
  410. extern pascal ProcPtr TEGetDefProc() inline(0x2222,dispatcher);
  411. extern pascal ProcPtr TEGetInternalProc() inline(0x2622,dispatcher);
  412. extern pascal Word TEGetLastError() inline(0x2722,dispatcher);
  413. extern pascal void TEGetRuler() inline(0x2322,dispatcher);
  414. extern pascal void TEGetSelection() inline(0x1C22,dispatcher);
  415. extern pascal Word TEGetSelectionStyle() inline(0x1E22,dispatcher);
  416. extern pascal LongWord TEGetText() inline(0x0C22,dispatcher);
  417. extern pascal void TEGetTextInfo() inline(0x0D22,dispatcher);
  418. extern pascal void TEIdle() inline(0x0E22,dispatcher);
  419. extern pascal void TEInsert() inline(0x1A22,dispatcher);
  420. extern pascal void TEInsertPageBreak() inline(0x1522,dispatcher);
  421. extern pascal void TEKey() inline(0x1422,dispatcher);
  422. extern pascal void TEKill() inline(0x0A22,dispatcher);
  423. extern pascal TERecordHndl TENew() inline(0x0922,dispatcher);
  424. extern pascal void TEOffsetToPoint() inline(0x2022,dispatcher);
  425. extern pascal LongWord TEPaintText() inline(0x1322,dispatcher);
  426. extern pascal void TEPaste() inline(0x1822,dispatcher);
  427. extern pascal LongWord TEPointToOffset() inline(0x2122,dispatcher);
  428. extern pascal void TEReplace() inline(0x1B22,dispatcher);
  429. extern pascal void TEReset() inline(0x0522,dispatcher);
  430. extern pascal void TEScroll() inline(0x2522,dispatcher);
  431. extern pascal void TESetRuler() inline(0x2422,dispatcher);
  432. extern pascal void TESetSelection() inline(0x1D22,dispatcher);
  433. extern pascal void TESetText() inline(0x0B22,dispatcher);
  434. extern pascal void TEShutDown() inline(0x0322,dispatcher);
  435. extern pascal void TEStartUp() inline(0x0222,dispatcher);
  436. extern pascal Word TEStatus() inline(0x0622,dispatcher);
  437. extern pascal void TEStyleChange() inline(0x1F22,dispatcher);
  438. extern pascal void TEUpdate() inline(0x1222,dispatcher);
  439. extern pascal Word TEVersion() inline(0x0422,dispatcher);
  440. #endif
  441.